package com.malty.rocketmq.controller;

import com.malty.rocketmq.manager.RocketMQManager;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author malty
 */
@RestController
@RequestMapping("/mq")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class RocketMQController {
    private final RocketMQManager rocketMQManager;

    @RequestMapping("/send")
    public void sendMsg(String msg) {
        rocketMQManager.sendMsg(msg);
    }

    @RequestMapping("/send/sideway")
    public void sendMsgSideWay(String msg) {
        rocketMQManager.sendMsgOneWay(msg);
    }

    @RequestMapping("/send/txMsg")
    public void sendTxMsg(String msg) {
        rocketMQManager.sendTxMsg(msg);
    }

    @RequestMapping("/send/delay")
    public void sendDelay(String msg) {
        rocketMQManager.sendDelayMsg(msg);
    }

    @RequestMapping("/send/orderly")
    public void sendOrderly(String msg) {
        rocketMQManager.sendSyncOrderMsg(msg);
    }
    @RequestMapping("/send/orderly/async")
    public void sendOrderlyAsync(String msg) {
        rocketMQManager.sendSyncOrderMsgAsync(msg);
    }
}
